package com.ruoyi.video.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.video.domain.VideoCamera;
import com.ruoyi.video.domain.VideoGroup;
import com.ruoyi.video.service.IVideoCameraService;
import com.ruoyi.video.service.IVideoGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 对外开放接口Controller
 * 
 * @author yepanpan
 * @date 2024-12-17
 */
@RestController
@RequestMapping("/open")
public class VideoOpenController extends BaseController
{
    @Autowired
    private IVideoCameraService videoCameraService;
    @Autowired
    private IVideoGroupService videoGroupService;

    /**
     * 查询摄像机列表
     */
    @GetMapping("/group")
    public AjaxResult group(VideoGroup videoGroup)
    {
        return success(videoGroupService.selectVideoGroupList(videoGroup));
    }

    /**
     * 查询摄像机列表
     */
    @GetMapping("/camera")
    public TableDataInfo list(VideoCamera videoCamera)
    {
        startPage();
        List<VideoCamera> list = videoCameraService.selectVideoCameraList(videoCamera);
        return getDataTable(list);
    }


    /**
     * 获取摄像机详细信息
     */
    @GetMapping(value = "/camera/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(videoCameraService.selectVideoCameraById(id));
    }


    /**
     * 获取摄像机流信息
     */
    @GetMapping(value = "/play/{id}")
    public AjaxResult playInfo(@PathVariable("id") Long id)
    {
        return success(videoCameraService.getVideoCameraStream(id));
    }

    /**
     * 获取摄像机流信息
     */
    @GetMapping(value = "/snap/{id}")
    public AjaxResult snap(@PathVariable("id") Long id)
    {
        return success(videoCameraService.snapVideoCamera(id));
    }
}
